<%--
 * list.jsp
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 --%>

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl"	uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags" %>


<display:table pagesize="5" class="displaytag" 
name="paintings" requestURI="${URI}" id="row">
	
	<!-- Attributes -->
	
	<spring:message code="painting.title" var="titleHeader" />
	<display:column property="title" title="${titleHeader}" sortable="true" />
	
	<spring:message code="painting.author" var="authorHeader" />
	<display:column property="author" title="${authorHeader}" sortable="true"/>
	
	<spring:message code="painting.date" var="dateHeader" />
	<display:column property="date" title="${dateHeader}" sortable="true"/>
	
	<security:authorize access="hasRole('ADMIN')">
		<spring:message code="painting.ownershipHistory" var="ownershipHistory"/>
		<display:column title="${ownershipHistory}" sortable="false">
		<input type="button" name="ownershipHistory" value="${ownershipHistory}"
			onclick="javascript: window.location.replace('ownership/admin/list.do?paintingId=${row.id}')" />
		</display:column>
	</security:authorize>
	
	<security:authorize access="hasRole('CUSTOMER')">
	<jstl:if test="${URI == \"/painting/customer/listCreated.do\"}">	
		<spring:message code="painting.edit" var="edit"/>
		<display:column title="${edit}" sortable="false">
		<input type="button" name="edit" value="${edit}"
			onclick="javascript: window.location.replace('painting/customer/edit.do?paintingId=${row.id}')" />
		</display:column>

		<spring:message code="painting.auction" var="auctionCreate"/>
		<display:column title="${auctionCreate}" sortable="false">
		<input type="button" name="auction" value="${auctionCreate}"
			onclick="javascript: window.location.replace('auction/customer/create.do?paintingId=${row.id}')" />
		</display:column>
	</jstl:if>
	<jstl:if test="${URI == \"/painting/customer/listCreated.do\" || URI == \"/painting/customer/listWithoutGalleries.do\" 
			|| URI == \"/painting/listInGallery.do\"}">
		<jstl:if test="${row.gallery!= null}">
		<spring:message code="painting.changeGallery" var="changeGallery"/>
		<display:column title="${changeGallery}" sortable="false">
		<input type="button" name="auction" value="${changeGallery}"
			onclick="javascript: window.location.replace('gallery/customer/listToChoose.do?paintingId=${row.id}')" />
		</display:column>
		</jstl:if>
		<jstl:if test="${row.gallery == null}">
		<spring:message code="painting.addToGallery" var="addToGallery"/>
		<display:column title="${addToGallery}" sortable="false">
		<input type="button" name="auction" value="${addToGallery}"
			onclick="javascript: window.location.replace('gallery/customer/listToChoose.do?paintingId=${row.id}')" />
		</display:column>
		</jstl:if>
	
	</jstl:if>
	
	</security:authorize>
	<spring:message code="painting.comments" var="comments"/>
			<display:column title="${comments}" sortable="false">
			<input type="button" name="comments" value="${comments}"
				onclick="javascript: window.location.replace('comment/list.do?paintingId=${row.id}')" />
			</display:column>
</display:table>